package com.veterinaria.dao;

import java.io.Reader;
import java.util.ArrayList;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.veterinaria.bean.AtencionBean;
import com.veterinaria.bean.HCBean;
import com.veterinaria.services.AtencionService;

public class AtencionDAO implements AtencionService{

	SqlSessionFactory sqlmapper= null;{
	   	 try {
	   	 Reader reader = Resources.getResourceAsReader("ConfiguracionIbatis.xml");
	   	 
	   	 sqlmapper =new  SqlSessionFactoryBuilder().build(reader);
	   	 } catch (Exception e) {
				e.printStackTrace();
			}
	    }

	@Override
	public ArrayList<AtencionBean> listarAtencion() throws Exception {
		// TODO Auto-generated method stub
		ArrayList<AtencionBean> lista = null;
		SqlSession session = sqlmapper.openSession();
		try {
			lista = (ArrayList<AtencionBean>)session.selectList("atencionxml.listaAtencion");
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			session.close();
		}
		return lista;
	}
	
}
